home *** CD-ROM | disk | FTP | other *** search
/ Aminet 5 / Aminet 5 - March 1995.iso / Aminet / util / gnu / a2_0b_Emacs_sr.lha / Emacs-19.25 / src / systty.h < prev    next >
C/C++ Source or Header  |  1994-08-13  |  10KB  |  425 lines

  1. /* systty.h - System-dependent definitions for terminals.
  2.    Copyright (C) 1993, 1994 Free Software Foundation, Inc.
  3.  
  4. This file is part of GNU Emacs.
  5.  
  6. GNU Emacs is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 1, or (at your option)
  9. any later version.
  10.  
  11. GNU Emacs is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GNU Emacs; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. #ifdef HAVE_TERMIOS
  21. #define HAVE_TCATTR
  22. #endif
  23.  
  24. /* If we defined these before and we are about to redefine them,
  25.    prevent alarming warnings.  */
  26. #ifdef BSD_TERMIOS
  27. #undef NL0
  28. #undef NL1
  29. #undef CR0
  30. #undef CR1
  31. #undef CR2
  32. #undef CR3
  33. #undef TAB0
  34. #undef TAB1
  35. #undef TAB2
  36. #undef XTABS
  37. #undef BS0
  38. #undef BS1
  39. #undef FF0
  40. #undef FF1
  41. #undef ECHO
  42. #undef NOFLSH
  43. #undef TOSTOP
  44. #undef FLUSHO
  45. #undef PENDIN
  46. #endif
  47.  
  48. /* Include the proper files.  */
  49. #ifdef HAVE_TERMIO
  50. #ifdef __DGUX
  51. #include <sys/ioctl.h>
  52. #endif
  53. #ifndef NO_TERMIO
  54. #include <termio.h>
  55. #endif /* not NO_TERMIO */
  56. #ifndef INCLUDED_FCNTL
  57. #define INCLUDED_FCNTL
  58. #include <fcntl.h>
  59. #endif
  60. #else /* not HAVE_TERMIO */
  61. #ifdef HAVE_TERMIOS
  62. #if defined(_AIX) && defined(_I386)
  63. #include <termios.h>        /* termios.h needs to be before termio.h */
  64. #include <termio.h>
  65. #else /* not HAVE_TERMIOS */
  66. #ifndef NO_TERMIO
  67. #include <termio.h>
  68. #endif
  69. #include <termios.h>
  70. #endif /* _AIX && _I386 */
  71. #define INCLUDED_FCNTL
  72. #include <fcntl.h>
  73. #else /* neither HAVE_TERMIO nor HAVE_TERMIOS */
  74. #ifndef VMS
  75. #ifndef MSDOS
  76. #ifndef AMIGA
  77. #include <sgtty.h>
  78. #endif
  79. #endif
  80. #else /* VMS */
  81. #include <descrip.h>
  82. static struct iosb
  83. {
  84.   short status;
  85.   short offset;
  86.   short termlen;
  87.   short term;
  88. } input_iosb;
  89.  
  90. extern int waiting_for_ast;
  91. extern int stop_input;
  92. extern int input_ef;
  93. extern int timer_ef;
  94. extern int process_ef;
  95. extern int input_eflist;
  96. extern int timer_eflist;
  97.  
  98. static $DESCRIPTOR (input_dsc, "TT");
  99. static int terminator_mask[2] = { 0, 0 };
  100.  
  101. static struct sensemode {
  102.   short status;
  103.   unsigned char xmit_baud;
  104.   unsigned char rcv_baud;
  105.   unsigned char crfill;
  106.   unsigned char lffill;
  107.   unsigned char parity;
  108.   unsigned char unused;
  109.   char class;
  110.   char type;
  111.   short scr_wid;
  112.   unsigned long tt_char : 24, scr_len : 8;
  113.   unsigned long tt2_char;
  114. } sensemode_iosb;
  115. #endif /* VMS */
  116. #endif /* not HAVE_TERMIOS */
  117. #endif /* not HAVE_TERMIO */
  118.  
  119. #ifdef __GNU_LIBRARY__
  120. #include <termios.h>
  121. #endif
  122.  
  123. #ifdef AIX
  124. /* Get files for keyboard remapping */
  125. #define HFNKEYS 2
  126. #include <sys/hft.h>
  127. #include <sys/devinfo.h>
  128. #endif
  129.  
  130. /* Get rid of LLITOUT in 4.1, since it is said to stimulate kernel bugs.  */
  131. #ifdef BSD4_1
  132. #undef LLITOUT
  133. #define LLITOUT 0
  134. #endif /* 4.1 */
  135.  
  136. #ifdef NEED_BSDTTY
  137. #include <sys/bsdtty.h>
  138. #endif 
  139.  
  140. #if defined (HPUX) && defined (HAVE_PTYS)
  141. #include <sys/ptyio.h>
  142. #endif
  143.   
  144. #ifdef AIX
  145. #include <sys/pty.h>
  146. #include <unistd.h>
  147. #define UNISTD_H_INCLUDED
  148. #endif /* AIX */
  149.  
  150. #ifdef IRIX4
  151. /* Get _getpty prototype */
  152. #include <unistd.h>
  153. #define UNISTD_H_INCLUDED
  154. #endif
  155.  
  156. #if defined (POSIX) && !defined (UNISTD_H_INCLUDED) && defined (HAVE_UNISTD_H)
  157. #include <unistd.h>
  158. #define UNISTD_H_INCLUDED
  159. #endif
  160.  
  161. #ifdef SYSV_PTYS
  162. #include <sys/types.h>
  163. #include <sys/tty.h>
  164. #ifdef titan
  165. #include <sys/ttyhw.h>
  166. #include <sys/stream.h>
  167. #endif
  168. #ifndef NO_PTY_H
  169. #include <sys/pty.h>
  170. #endif
  171. #endif
  172.  
  173. /* saka@pfu.fujitsu.co.JP writes:
  174.    FASYNC defined in this file. But, FASYNC don't working.
  175.    so no problem, because unrequest_sigio only need. */
  176. #if defined (pfa)
  177. #include <sys/file.h>
  178. #endif
  179.  
  180.  
  181. /* Special cases - inhibiting the use of certain features.  */
  182.  
  183. #ifdef APOLLO
  184. #undef TIOCSTART
  185. #endif
  186.  
  187. #ifdef XENIX
  188. #undef TIOCGETC  /* Avoid confusing some conditionals that test this.  */
  189. #endif
  190.  
  191. #ifdef BROKEN_TIOCGETC
  192. #undef TIOCGETC  /* Avoid confusing some conditionals that test this.  */
  193. #endif
  194.  
  195. /* UNIPLUS systems may have FIONREAD.  */
  196. #ifdef UNIPLUS
  197. #include <sys.ioctl.h>
  198. #endif
  199.  
  200. /* Allow m- file to inhibit use of FIONREAD.  */
  201. #ifdef BROKEN_FIONREAD
  202. #undef FIONREAD
  203. #undef ASYNC
  204. #endif
  205.  
  206. /* Interrupt input is not used if there is no FIONREAD.  */
  207. #ifndef FIONREAD
  208. #undef SIGIO
  209. #endif
  210.  
  211. /* On TERMIOS systems, the tcmumbleattr calls take care of these
  212.    parameters, and it's a bad idea to use them (on AIX, it makes the
  213.    tty hang for a long time).  */
  214. #if defined (TIOCGLTC) && !defined (HAVE_TERMIOS)
  215. #define HAVE_LTCHARS
  216. #endif
  217.  
  218. #if defined (TIOCGETC) && !defined (HAVE_TERMIOS)
  219. #define HAVE_TCHARS
  220. #endif
  221.  
  222.  
  223. /* Try to establish the correct character to disable terminal functions
  224.    in a system-independent manner.  Note that USG (at least) define
  225.    _POSIX_VDISABLE as 0!  */
  226.  
  227. #ifdef _POSIX_VDISABLE
  228. #define CDISABLE _POSIX_VDISABLE
  229. #else /* not _POSIX_VDISABLE */
  230. #ifdef CDEL
  231. #undef CDISABLE
  232. #define CDISABLE CDEL
  233. #else /* not CDEL */
  234. #define CDISABLE 255
  235. #endif /* not CDEL */
  236. #endif /* not _POSIX_VDISABLE */
  237.  
  238. /* Get the number of characters queued for output.  */
  239.  
  240. /* EMACS_OUTQSIZE(FD, int *SIZE) stores the number of characters
  241.    queued for output to the terminal FD in *SIZE, if FD is a tty.
  242.    Returns -1 if there was an error (i.e. FD is not a tty), 0
  243.    otherwise.  */
  244. #ifdef TIOCOUTQ
  245. #define EMACS_OUTQSIZE(fd, size) (ioctl ((fd), TIOCOUTQ, (size)))
  246. #endif
  247.  
  248. #ifdef HAVE_TERMIO
  249. #ifdef TCOUTQ
  250. #undef EMACS_OUTQSIZE
  251. #define EMACS_OUTQSIZE(fd, size) (ioctl ((fd), TCOUTQ, (size)))
  252. #endif
  253. #endif
  254.  
  255.  
  256. /* Manipulate a terminal's current process group.  */
  257.  
  258. /* EMACS_HAVE_TTY_PGRP is true if we can get and set the tty's current
  259.    controlling process group.
  260.  
  261.    EMACS_GET_TTY_PGRP(int FD, int *PGID) sets *PGID the terminal FD's
  262.    current process group.  Return -1 if there is an error.
  263.  
  264.    EMACS_SET_TTY_PGRP(int FD, int *PGID) sets the terminal FD's
  265.    current process group to *PGID.  Return -1 if there is an error.  */
  266.  
  267. #ifdef HPUX
  268. /* HPUX tty process group stuff doesn't work, says the anonymous voice
  269.    from the past.  */
  270. #else
  271. #ifdef TIOCGPGRP
  272. #define EMACS_HAVE_TTY_PGRP
  273. #else
  274. #ifdef HAVE_TERMIOS
  275. #define EMACS_HAVE_TTY_PGRP
  276. #endif
  277. #endif
  278. #endif
  279.  
  280. #ifdef EMACS_HAVE_TTY_PGRP
  281.  
  282. #if defined (HAVE_TERMIOS) && ! defined (BSD_TERMIOS)
  283.  
  284. #define EMACS_GET_TTY_PGRP(fd, pgid) (*(pgid) = tcgetpgrp ((fd)))
  285. #define EMACS_SET_TTY_PGRP(fd, pgid) (tcsetpgrp ((fd), *(pgid)))
  286.  
  287. #else
  288. #ifdef TIOCSPGRP
  289.  
  290. #define EMACS_GET_TTY_PGRP(fd, pgid) (ioctl ((fd), TIOCGPGRP, (pgid)))
  291. #define EMACS_SET_TTY_PGRP(fd, pgid) (ioctl ((fd), TIOCSPGRP, (pgid)))
  292.  
  293. #endif
  294. #endif
  295.  
  296. #else
  297.  
  298. /* Just ignore this for now and hope for the best */
  299. #define EMACS_GET_TTY_PGRP(fd, pgid) 0
  300. #define EMACS_SET_TTY_PGRP(fd, pgif) 0
  301.  
  302. #endif
  303.  
  304. /* EMACS_GETPGRP (arg) returns the process group of the terminal.  */
  305.  
  306. #if defined (USG) && !defined (GETPGRP_NEEDS_ARG)
  307. #  if !defined (GETPGRP_NO_ARG)
  308. #    define GETPGRP_NO_ARG
  309. #  endif
  310. #endif
  311.  
  312. #if defined (GETPGRP_NO_ARG)
  313. #  define EMACS_GETPGRP(x) getpgrp()
  314. #else
  315. #  define EMACS_GETPGRP(x) getpgrp(x)
  316. #endif /* !GETPGRP_NO_ARG */
  317.  
  318. /* Manipulate a TTY's input/output processing parameters.  */
  319.  
  320. /* struct emacs_tty is a structure used to hold the current tty
  321.    parameters.  If the terminal has several structures describing its
  322.    state, for example a struct tchars, a struct sgttyb, a struct
  323.    tchars, a struct ltchars, and a struct pagechars, struct
  324.    emacs_tty should contain an element for each parameter struct
  325.    that Emacs may change.
  326.  
  327.    EMACS_GET_TTY (int FD, struct emacs_tty *P) stores the parameters
  328.    of the tty on FD in *P.  Return zero if all's well, or -1 if we ran
  329.    into an error we couldn't deal with.
  330.  
  331.    EMACS_SET_TTY (int FD, struct emacs_tty *P, int waitp)
  332.    sets the parameters of the tty on FD according to the contents of
  333.    *P.  If waitp is non-zero, we wait for all queued output to be
  334.    written before making the change; otherwise, we forget any queued
  335.    input and make the change immediately.
  336.    Return 0 if all went well, and -1 if anything failed.
  337.  
  338.    EMACS_TTY_TABS_OK (struct emacs_tty *P) is false iff the kernel
  339.    expands tabs to spaces upon output; in that case, there is no
  340.    advantage to using tabs over spaces.  */
  341.  
  342.  
  343. /* For each tty parameter structure that Emacs might want to save and restore,
  344.    - include an element for it in this structure, and
  345.    - extend the emacs_{get,set}_tty functions in sysdep.c to deal with the
  346.      new members.  */
  347.  
  348. struct emacs_tty {
  349.  
  350. /* There is always one of the following elements, so there is no need
  351.    for dummy get and set definitions.  */
  352. #ifdef HAVE_TCATTR
  353.   struct termios main;
  354. #else
  355. #ifdef HAVE_TERMIO
  356.   struct termio main;
  357. #else
  358. #ifdef VMS
  359.   struct sensemode main;
  360. #else
  361. #if defined(MSDOS) || defined(AMIGA)
  362.   int main;
  363. #else
  364.   struct sgttyb main;
  365. #endif
  366. #endif
  367. #endif
  368. #endif
  369.  
  370. /* If we have TERMIOS, we don't need to do this - they're taken care of
  371.    by the tc*attr calls.  */
  372. #ifndef HAVE_TERMIOS
  373. #ifdef HAVE_LTCHARS
  374.   struct ltchars ltchars;
  375. #endif
  376.  
  377. #ifdef HAVE_TCHARS
  378.   struct tchars tchars;
  379.   int lmode;
  380. #endif
  381. #endif
  382. };
  383.  
  384. /* Define EMACS_GET_TTY and EMACS_SET_TTY,
  385.    the macros for reading and setting parts of `struct emacs_tty'.
  386.  
  387.    These got pretty unmanageable (huge macros are hard to debug), and
  388.    finally needed some code which couldn't be done as part of an
  389.    expression, so we moved them out to their own functions in sysdep.c.  */
  390. #define EMACS_GET_TTY(fd, p)        (emacs_get_tty ((fd), (p)))
  391. #define EMACS_SET_TTY(fd, p, waitp) (emacs_set_tty ((fd), (p), (waitp)))
  392.  
  393.  
  394. /* Define EMACS_TTY_TABS_OK.  */
  395.  
  396. #ifdef HAVE_TERMIOS
  397.  
  398. #ifdef TABDLY
  399. #define EMACS_TTY_TABS_OK(p) (((p)->main.c_oflag & TABDLY) != TAB3)
  400. #else
  401. #define EMACS_TTY_TABS_OK(p) 1
  402. #endif
  403.  
  404. #else /* not def HAVE_TERMIOS */
  405. #ifdef HAVE_TERMIO
  406.  
  407. #define EMACS_TTY_TABS_OK(p) (((p)->main.c_oflag & TABDLY) != TAB3)
  408.  
  409. #else /* neither HAVE_TERMIO nor HAVE_TERMIOS */
  410. #ifdef VMS
  411.  
  412. #define EMACS_TTY_TABS_OK(p) (((p)->main.tt_char & TT$M_MECHTAB) != 0)
  413.  
  414. #else
  415.  
  416. #if defined(MSDOS) || defined(AMIGA)
  417. #define EMACS_TTY_TABS_OK(p) 0
  418. #else /* not MSDOS */
  419. #define EMACS_TTY_TABS_OK(p) (((p)->main.sg_flags & XTABS) != XTABS)
  420. #endif /* not MSDOS */
  421.  
  422. #endif /* not def VMS */
  423. #endif /* not def HAVE_TERMIO */
  424. #endif /* not def HAVE_TERMIOS */
  425.